<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<%
	String path = request.getContextPath();
%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="renderer" content="webkit">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>项目信息</title>
<jsp:include page="../../import.jsp" flush="true" />
<style type="text/css">
.acolor{color:#0000EF; text-decoration:none;font-weight:bold;}/*链接设置*/
  a:link{text-decoration: none; color:blue; font-family: 微软雅黑;}
	a:visited{color:green;}
	a:hover{text-decoration: underline; color:#09f;}
</style>
</head>
<body class="iframeBody">
 <div class="Wrapper">
        <div>
           <div id="pageInTab" class="pageInTab">
		   <div tabid="tabA" title="基本信息" lselected="true">
		<form id="fnc_prj_bsc_info_form" >
             <div class="fieldset1 tabel_col clearFix">
              <div class="fieldBox col_50">
                 <div class="label">项目名称:</div>
                <div class="field">
                    <span id="fncprjnm" name="fncprjnm">&nbsp;${fncPrjBscInfo.fncprjnm}</span>
                </div>
             </div>
                <div class="fieldBox col_50">
                 <div class="label">金融机构</div>
                <div class="field">
                     <span id="fncinsNM" name="fncinsNM">&nbsp;${fncPrjBscInfo.fncinsNM}</span>
                </div> 
             </div>
                <div class="fieldBox col_50">
                    <div class="label">金融机构类型</div>
                    <div class="field">
                  <span id="instypeNM" name="instypeNM">&nbsp;${fncPrjBscInfo.instypeNM}</span>
                </div>
             </div>
             <div class="fieldBox col_50">
              <div class="label">融资报价</div>
                <div class="field">
					<c:choose>
						<c:when test="${pflag!=null && pflag=='002'}">
						    <c:choose>
								<c:when test="${scmBaseInfo.scmSt!=null && (scmBaseInfo.scmSt=='1' || scmBaseInfo.scmSt=='2')}"><!-- 已保存，可修改；已审核，不可修改 -->
									<a class="acolor" href="javascript:modifyScmBaseinfo('${fncPrjBscInfo.fncscmid }')">&nbsp;${fncPrjBscInfo.fncscmNM}</a>
								</c:when>
								<c:otherwise>
									<span >&nbsp;${fncPrjBscInfo.fncscmNM}</span>
								</c:otherwise>
					        </c:choose>
						</c:when>
						<c:otherwise>
								<span >&nbsp;${fncPrjBscInfo.fncscmNM}</span>
						</c:otherwise>
					</c:choose>
					<%-- <a href="javascript:modifyScmBaseinfo('${fncPrjBscInfo.fncscmid }')">&nbsp;${fncPrjBscInfo.fncscmNM}</a> --%>
               </div>
             </div>
           <div class="fieldBox col_50">
            <div class="label">国家</div>
                <div class="field">
               <span id="countryNM" name="countryNM">&nbsp;${fncPrjBscInfo.countryNM}</span>
              </div>
             </div>
		 <div class="fieldBox col_50">
                <div class="label">业务类型</div>
                <div class="field">
                <span id="bustypeNM" name="bustypeNM">&nbsp;${fncPrjBscInfo.bustypeNM}</span>
                </div>
                <div style="display: none">
                </div>
              </div>
          <div class="fieldBox col_50">
             <div class="label">项目金额</div>
             <div class="field">
                   <span id="fncprjamt" name="fncprjamt">&nbsp;${fncPrjBscInfo.fncprjamt/100}</span>
             </div>
          </div> 
         <div class="fieldBox col_50">
           <div class="label">融资金额</div>
            <div class="field">
                <span id="fncfiamt" name="fncfiamt">&nbsp;${fncPrjBscInfo.fncfiamt/100}</span>
            </div>
          </div>
          <div class="fieldBox col_50">
           <div class="label">支付表数量</div>
            <div class="field">
                <span id="paySchCount" name="paySchCount">&nbsp;${fncPrjBscInfo.paySchCount}</span>
            </div>
          </div>   
           <div class="fieldBox col_50">
           <div class="label">折扣率</div>
            <div class="field">
                <span id="dcnRate" name="dcnRate">&nbsp;${fncPrjBscInfo.dcnRate*100}%</span>
           
            </div>
          </div> 
           <c:if test="${not empty fncPrjBscInfo.expwdamt}"> 
          
         <div class="fieldBox col_50">
           <div class="label">预放款金额</div>
            <div class="field">
                <span id="expwdamt" name="expwdamt">&nbsp;${fncPrjBscInfo.expwdamt/100}</span>
            </div>
          </div> 
          <div class="fieldBox col_50">
           <div class="label">预放款日期</div>
            <div class="field">
                <span id="expwddate" name="expwddate">&nbsp;${fncPrjBscInfo.expwddate}</span>
            </div>
          </div> 
            <div class="fieldBox col_50">
                    <div class="label">预放款收款账号</div>
                <div class="field">
                 <span id="expwdacc" name="expwdacc">&nbsp;${fncPrjBscInfo.expwdaccNM}</span>
                   
                </div>

             </div>  
               <div class="fieldBox col_50">
                    <div class="label">预放款收款银行</div>
                <div class="field">
                       <span id="expwdbank" name="expwdbank">&nbsp;${fncPrjBscInfo.expwdbank}</span>
                </div>
             </div>            
          </c:if>  
          <c:if test="${not empty fncPrjBscInfo.acFiAmt}"> 
          
         <div class="fieldBox col_50">
           <div class="label">实际融资金额</div>
            <div class="field">
                <span id="acFiAmt" name="acFiAmt">&nbsp;${fncPrjBscInfo.acFiAmt/100}</span>
            </div>
          </div> 
          <div class="fieldBox col_50">
           <div class="label">首付款金额</div>
            <div class="field">
                <span id="fstpyamtall" name="fstpyamt">&nbsp;${fncPrjBscInfo.fstpyamtall/100}</span>
            </div>
          </div> 
           
          </c:if>  
          <div class="fieldBox col_50">
           <div class="label">授信名称</div>
            <div class="field">
          		<c:choose>
					<c:when test="${pflag!=null && pflag=='002'}">
					    <c:choose>
							<c:when test="${crBaseInfo.crSt!=null && (crBaseInfo.crSt=='0' || crBaseInfo.crSt=='2')}"><!-- 未授信 可修改；正常，不可修改 -->
								<a class="acolor" href="javascript:modifycrBase('${crBaseInfo.id }')">&nbsp;${crBaseInfo.crNm}</a>
							</c:when>
							<c:otherwise>
								<span>&nbsp;${crBaseInfo.crNm}</span>
							</c:otherwise>
				        </c:choose>
					</c:when>
					<c:otherwise>
						<span>&nbsp;${crBaseInfo.crNm}</span>
					</c:otherwise>
				</c:choose>
            	<%-- <a href="javascript:modifycrBase('${crBaseInfo.id }')">&nbsp;${crBaseInfo.crNm}</a> --%>
            </div>
          </div>  
          <div class="fieldBox col_50">
           <div class="label">产品名称</div>
            <div class="field">
            	${fncPrjBscInfo.pdNm}
            </div>
          </div>  
          <div class="fieldBox col_50">
           <div class="label">授信状态</div>
            <div class="field">
            	${crBaseInfo.crStNm}
            </div>
          </div>  
          <div class="fieldBox col_50">
           <div class="label">报价状态</div>
            <div class="field">
            	${scmBaseInfo.scmDes}
            </div>
          </div>  
          <div class="fieldBox col_50">
           <div class="label">是否出表</div>
            <div class="field">
            	${fncPrjBscInfo.isOutNm}
            </div>
          </div>     
          <div class="fieldBox col_50">
           	<div class="label">合同审核</div>
            <div class="field">
            	${fncPrjBscInfo.contractAuditNm}
            </div>
          </div>
        <!-- 是否分账  add by gengchunlan 20200304 --> 
         <div class="fieldBox col_50">
               <div class="label">是否分账</div>
                    <div class="field">
                        	<c:if test="${fncPrjBscInfo.isSplitAccount==2}">否</c:if>  
                        	<c:if test="${fncPrjBscInfo.isSplitAccount==1}">是</c:if>  
                    </div>
         </div>
         <div class="fieldBox col_50">
               <div class="label">分账业务短信提醒</div>
                    <div class="field">
                        	<c:if test="${fncPrjBscInfo.isSplitMsg!='1'}">否</c:if> 
                        	<c:if test="${fncPrjBscInfo.isSplitMsg=='1'}">是</c:if>  
                    </div>
         </div>  
         <!-- end by gengchunlan  20200304--> 
  		<!--分账账户信息-->
         <div class="fieldBox col_100">
                 <div class="field">
                 </div>
         </div>  
         <c:if test="${fncPrjBscInfo.isSplitAccount==1}" >
	         <table id="tableBank2" class="sq-formTable no-border" style="width:80%" >
					<thead>
						<tr>
						    <th class="tbLabel" style="text-align: right;background:#e7fef4;width:10% ;">支付通道</th>
							<th class="tbLabel" style="text-align: center;width:30% ;background:#e7fef4;" >分账账户</th>
							<th class="tbLabel" style="text-align: left;width:15% ; background:#e7fef4;border-right: 1px solid #e9e9e9; ">分账比例(%)</th>
							<th class="tbLabel" style="text-align: left;width:10% ; background:#e7fef4; ">是否存在备用通道</th>
							<th class="tbLabel" style="text-align: center;width:20% ;background:#e7fef4;border-right: 1px solid #e9e9e9; " >机构名称</th>
							<th class="tbLabel" style="text-align: center;width:10% ;background:#e7fef4;border-right: 1px solid #e9e9e9; " >机构code</th>
							<th class="tbLabel" style="text-align: center;width:15% ;background:#e7fef4;border-right: 1px solid #e9e9e9; " >操作</th>
						</tr>
					</thead>
					<tbody>
						<c:forEach items="${fncPrjBscInfo.fncPrjSplitAccountList }" var="splitItem">
							<tr>
								<td style="text-align: right;line-height: 20px;">
						        	<c:forEach var="payMayItem" items="${payMayList}">
								     	<c:if test="${payMayItem.key==splitItem.payMay}" > ${payMayItem.value } </c:if> 
							     	</c:forEach>
								</td>
								<td style="text-align: center;line-height: 20px;">${splitItem.splitAccount }</td>
								<td style="border-right: 1px solid #e9e9e9;line-height: 20px;">${splitItem.splitRatio }</td>
								<td style="border-right: 1px solid #e9e9e9;line-height: 10px;">
								  <c:if test="${ empty splitItem.isBack}">否 </c:if> 
								  <c:if test="${not empty splitItem.isBack}">${splitItem.isBack } </c:if> 
								</td>
								<td style="border-right: 1px solid #e9e9e9;line-height: 20px;">${splitItem.fundInsNm }</td>
								<td style="border-right: 1px solid #e9e9e9;line-height: 20px;">${splitItem.insCode }</td>
								<td style="border-right: 1px solid #e9e9e9;line-height: 15px;">
									<c:choose>
										<c:when test="${splitItem.isBack=='是'}">
										   <a href="javascript:void(0)" onclick="openBackView('${splitItem.id }')" >查看备用通道</a>
										</c:when>
										<c:otherwise> 
											<font color='#CCCCCC'>查看备用通道</font>
										</c:otherwise>
									</c:choose>
								</td>
							</tr>
						</c:forEach>
				 	</tbody>
	       		</table>
         </c:if>
         <!-- 分账账户信息 -->  
         </div>
         </form>
         </div>
              <div tabid="tabB" title="资产包信息" id="tabBId" style="display: none;">
                    <iframe frameborder="0" name="tabB" id="tabB" src=""></iframe>
             </div>

        </div>
        </div>
    </div>
 <!-- 查看备用账户弹出框 -->
<div id="openBackDiv" style="display:none;">
    <form id="openBackForm" ><!-- fncPrjId -->
         <div class="sqPanel_body">
             <div id="ligergrid_back" class="sq-grid"  ></div>
         </div>
    </form>
</div>   
	<script type="text/javascript">
	  var pageInApp={
	    		flag:true
	    };
	$(function () {
		initTab();
	    $("#fncfiamt").html(fmoney(new  Number("${fncPrjBscInfo.fncfiamt/100}"), 2));
	    $("#fncprjamt").html(fmoney(new  Number("${fncPrjBscInfo.fncprjamt/100}"), 2));
	    $("#acFiAmt").html(fmoney(new  Number("${fncPrjBscInfo.acFiAmt/100}"), 2));
	    $("#fstpyamt").html(fmoney(new  Number("${fncPrjBscInfo.fstpyamt/100}"), 2));
	    $("#expwdamt").html(fmoney(new  Number("${fncPrjBscInfo.expwdamt/100}"), 2));
	    
	    var expwddate ="${fncPrjBscInfo.expwddate}";
		if(null != expwddate&&expwddate!=''){
			var date = new Date(expwddate);
			$("#expwddate").text(DateUtils.formatDate(date, DateUtils.YYYY_MM_DD));
		}
	
	});
	//初始化Tab
		var pageInTab = null;
	  var loadedTabs=[]
    function initTab(){
    	 pageInTab = $("#pageInTab").ligerTab({
             height: 'auto',
             contextmenu: false,
             minIframeHeight: GET_minIframeHeight(),
             onBeforeSelectTabItem: function (tabid) {
             	var id = "${id}";
             		//alert("id="+id);
             	 if(tabid!="tabA"){
 	             	if(id==null||id==''){
 	                	top.$.ligerDialog.SQalert({content:"请先保存项目基本信息", SQ_type: "warning"});
 	                	return false;
 	                } 
             	} 
             },
             onAfterSelectTabItem: function(tabid) {
              //   if (loadedTabs.indexOf(tabid)<0) {
                 	var id = "${id}";
                 	//alert("id="+id);
                 	 if(tabid!="tabA"){
 	                	if(id==null||id==''){
 	                		 top.$.ligerDialog.SQalert({content: LogUtils.LOG_PRJ__PRD_SELECT_BEFORE, SQ_type: "warning"});
 	                         return false; //验证不通过，不执行以下代码
 	                	}
                 	} 
                     loadedTabs.push(tabid);
                     switch (tabid){
                         case "tabB":
                        
                        	 pageInTab.setTabItemSrc(tabid, "<%=path%>/rfbuss/fncprjbscinfo/viewAssPackInfoDetail.do?prjid="+id+"&&flag=2");
                             break;
                         case "tabD":
                             
                        	 pageInTab.setTabItemSrc(tabid, "<%=path%>/rfbase/fncprjpaysch/toRepayModifyPage.do?projid="+id);
                             break;
                         case "tabC":
                             
                        	 pageInTab.setTabItemSrc(tabid, "<%=path%>/rfbuss/fncprjbscinfo/tofstpyDetailPage.do?fncPrjId="+id);
                             break;    
                     }
            //     };
                 SetIframe_height();
             }
         });

         $.extend(true, pageInApp, {
             pageInTab: pageInTab
         });
    };
    function fmoney(s, n)   
	{   
	   n = n > 0 && n <= 20 ? n : 2;   
	   s = parseFloat((s + "").replace(/[^\d\.-]/g, "")).toFixed(n) + "";   
	   var l = s.split(".")[0].split("").reverse(),   
	   r = s.split(".")[1];   
	   t = "";   
	   for(i = 0; i < l.length; i ++ )   
	   {   
	      t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? "," : "");   
	   }   
	   return t.split("").reverse().join("") + "." + r;   
	} 
    //查看融资报价
    function showDetail(id){
		var callback = function(){
			 grid.reload();
		}
		var timestamp=new Date().getTime();
		Add_navTab( 'tab_scm_bsc_info_detl'+timestamp,'查看融资报价','<%=path%>/rfbase/scmbaseinfo/toDetail.do?id='+id,callback);
  	}//修改授信信息
    function modifycrBase(id){
		var lgcId=id;
		Add_navTab('PrdSpl_2'+id,'修改授信','<%=path%>/rfbase/crbaseinfo/toAddPage.do?lgcId='+lgcId);
	};
	//修改报价信息
	function modifyScmBaseinfo(_id){
		var timestamp=new Date().getTime();
		Add_navTab( 'tab_scm_bsc_info_mod'+timestamp,'修改融资报价','<%=path%>/rfbase/scmbaseinfo/toModifyPage.do?fncScmId='+_id);
  	}
	</script>
<script type="text/javascript">
	//新增 备用通道弹窗
	function  openBackView(mainAccountId){
		 	//alert(mainAccountId+"@"+obj);
		   	if(mainAccountId == '' || mainAccountId == null || mainAccountId == 'undefined'){
		   		top.$.ligerDialog.SQalert({content: "请先点击保存按钮，添加主通道!",SQ_type: "success"});
		   		return ;
		   	}
		   $.ligerDialog.open({
	           width: 500,
	           height: 300,
	           isResize: true,
	           title : '备用通道',
	           target: $("#openBackDiv"),
	           onHideDialog: function () {
	               clearLigerForm("openBackForm");
	           }
	       });
		   
		   var ligerForm = $("#openBackForm").ligerForm({validate: true});
		   initBackGrid(mainAccountId);
	   }
	//初始化备用账户信息
	function initBackGrid(mainAccountId) {
		//主账户id
	   	if(mainAccountId == '' || mainAccountId == null || mainAccountId == 'undefined'){
	   		top.$.ligerDialog.SQalert({content: "请先点击保存按钮，添加主通道!",SQ_type: "success"});
	   		return ;
	   	}
	   	var fncPrjId = "${id}";//再融资项目id
	    backGrid = $("#ligergrid_back").ligerGrid({
	            url: '<%=path%>/rfbuss/fncprjbscinfo/initBackList.do?',
		    	method : 'get',
		    	parms:{"fncPrjId":fncPrjId,"mainAccountId":mainAccountId},
		    	async: false,
		    	columns: [
			    		{ display: '备用支付通道', name: 'payMay', width: 100,
							valueField: 'payMay',
							textField: 'payMayNm',
							render: function (item) {
								return item.payMayNm;
							},
							validate: function (value) {
							  if (StringUtils.isEmpty(value)) return "此项为必填项！";
							}
		  	            },
						{ display: '备用分账账户', name: 'splitAccount', width: 200}
		   	  	        ],
		   	  	   usePager: false,
		           root: 'rows',
		           record: 'total',
		           hideLoadButton: true,
		           resizable: false, 
		           width: 470,
		           height: 250,
		           //heightDiff: -2,
				   enabledEdit: true,
		           isScroll: false,
		           checkbox: false,
		           rownumbers: true,
		           allowUnSelectRow: true,
		           alternatingRow: false,
		           enabledSort:false,
		    });
	};
</script>
</body>
</html>